use std::sync::Arc;

use crate::{Engine, EngineBuilder, SearchConfig, SearchResult, SearchResultItem};

pub struct MixedEngine {
    engines : Vec<EngineProfile>
}

pub struct EngineProfile {
    engine: Arc<dyn Engine>,
    search_config: SearchConfig,
}

impl Engine for MixedEngine {
    async fn search(
            &self,
            inputs: &[f32],
            config: &SearchConfig,
        ) -> anyhow::Result<crate::SearchResult>{
        let mut res = self.engines.iter().flat_map(|engine| {
            let profile = &engine.search_config;
            let engine = engine.engine.clone();
            tokio::spawn(move | | {
                engine.search(inputs, config).unwrap().into::<Vec<SearchResultItem>>()
            })
        })
        .collect::<Vec<SearchResultItem>>();
        res.sort();
        Ok(SearchResult {
            items: res,
        })
    }
}
impl MixedEngine {

}


